import smtplib
from email.mime.text import MIMEText
from email.utils import formataddr

# 设置邮件内容
message = MIMEText('这是一封测试邮件', 'plain', 'utf-8')
message['From'] = formataddr(('郑增亮', '435949837@qq.com'))
message['To'] = formataddr(('郑增亮', 'zhengzengliang@botanee.com'))
message['Subject'] = '测试邮件主题'

# 发送邮件
try:
    smtpObj = smtplib.SMTP('smtp.qq.com')  # 替换为你的SMTP服务器地址
    smtpObj.login('435949837@qq.com', 'uowmvyzaisqrbhdg')  # 替换为你的邮箱地址和密码
    smtpObj.sendmail('435949837@qq.com', ['zhengzengliang@botanee.com'], message.as_string())
    print("邮件发送成功")
except smtplib.SMTPException as e:
    print("邮件发送失败:", e)
